﻿using System;
using System.Collections.Generic;

using System.Web;
using com.byt.webcore;
using com.byt.suce.db.dao;
using com.byt.suce.db.factory;
using com.byt.suce.db.mapper;
using MYLSOFT.JsonSimple;
using com.byt.webcore.utils;
using suce.upload;

namespace suce.gestor
{
    /// <summary>
    /// Summary description for Dr
    /// </summary>
    public class Dr : ServletBase
    {

        private IPkgDr DAO = PkgDrFactory.create();

        protected override void doCommand(com.byt.webcore.ServletBase.Parameters p)
        {
            if ("DRA".Equals(p.command))
                DRA(p);
            else if ("DRD".Equals(p.command))
                DRD(p);

        }

        private void DRA(Parameters p)
        {
            if ("UPDATE".Equals(p.subcommand))
            {
                PkgDr.AprobUpdateParam param = PkgDrFactory.create().aprobUpdate(p.conn, p.getMap());

            }
            else if ("GETBYID".Equals(p.subcommand))
            {
                PkgDr.AprobGetbyidParam param = PkgDrFactory.create().aprobGetbyid(p.conn, p.getMap());
                JSONObject jo = new JSONObject();
                jo.Add("form", Utils.getJSONObject(param.CurOut));
                //jo.Add("files", UploadHelper.ListFiles("DRA" + param.Iddr));
                p.print(jo);
                param.CurOut.Close();

            }
        }

        private void DRD(Parameters p)
        {
            if ("UPDATE".Equals(p.subcommand))
            {
                PkgDr.DenegUpdateParam param = PkgDrFactory.create().denegUpdate(p.conn, p.getMap());

            }
            else if ("GETBYID".Equals(p.subcommand))
            {
                PkgDr.DenegGetbyidParam param = PkgDrFactory.create().denegGetbyid(p.conn, p.getMap());
                JSONObject jo = new JSONObject();
                jo.Add("form", Utils.getJSONObject(param.CurOut));
                //jo.Add("files", UploadHelper.ListFiles("DRA" + param.Iddr));
                p.print(jo);
                param.CurOut.Close();

            }
        }

    }
}